<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

//用户后台
Route::auth();
Route::group(['prefix' => 'user'], function () {
    Route::match(['get', 'post'], '/', 'User\IndexController@index')->name('user.index.index');

    Route::get('{chunk}/info', 'User\InfoController@info')->name('user.chunk.info');
    Route::match(['get', 'post'], '{chunk}/info/add', 'User\InfoController@info_add')->name('user.chunk.info_add');
    Route::match(['get', 'post'], '{chunk}/info/edit/{id}', 'User\InfoController@info_edit')->name('user.chunk.info_edit');

    Route::get('logout', 'User\IndexController@logout')->name('user.index.logout');
});

//管理员后台
Route::group(['prefix' => 'admin', 'namespace' => 'Admin'], function () {
    Route::get('login', 'AuthController@getLogin')->name('admin.auth.getlogin');
    Route::post('login', 'AuthController@postLogin')->name('admin.auth.postlogin');
    Route::get('register', 'AuthController@getRegister')->name('admin.auth.getregister');
    Route::post('register', 'AuthController@postRegister')->name('admin.auth.postregister');
    Route::get('logout', 'ServerController@logout')->name('admin.index.logout');
    Route::get('repwd', 'ServerController@repwd')->name('admin.index.repwd');

    Route::get('/', 'IndexController@index')->name('admin.index.index');

    Route::get('versions', 'IndexController@versions')->name('admin.index.versions');
    Route::match(['get', 'post'], 'versions/add', 'IndexController@versions_add')->name('admin.index.versions_add');
    Route::match(['get', 'post'], 'versions/edit/{id}', 'IndexController@versions_edit')->name('admin.index.versions_edit');

    Route::get('operate', 'IndexController@operate')->name('admin.index.operate');

    Route::get('help', 'IndexController@help')->name('admin.index.help');
    Route::match(['get', 'post'], 'help/add', 'IndexController@help_add')->name('admin.index.help_add');
    Route::match(['get', 'post'], 'help/edit/{id}', 'IndexController@help_edit')->name('admin.index.help_edit');

    Route::match(['get', 'post'], 'opinion', 'IndexController@opinion')->name('admin.index.opinion');

    Route::match(['get', 'post'], 'set', 'IndexController@set')->name('admin.index.set');

    Route::get('admin', 'IndexController@admin')->name('admin.index.admin');
    Route::match(['get', 'post'], 'admin_add', 'IndexController@admin_add')->name('admin.index.admin_add');
    Route::match(['get', 'post'], 'admin_edit/{id}', 'IndexController@admin_edit')->name('admin.index.admin_edit');

    Route::get('area', 'IndexController@area')->name('admin.index.area');
    Route::match(['get', 'post'], 'area_add', 'IndexController@area_add')->name('admin.index.area_add');
    Route::match(['get', 'post'], 'area_edit/{id}', 'IndexController@area_edit')->name('admin.index.area_edit');

    Route::get('pagelabel', 'PageController@pagelabel')->name('admin.page.pagelabel');
    Route::match(['get', 'post'], 'pagelabel_add', 'PageController@pagelabel_add')->name('admin.page.pagelabel_add');
    Route::match(['get', 'post'], 'pagelabel_edit/{id}', 'PageController@pagelabel_edit')->name('admin.page.pagelabel_edit');

    Route::get('pageinfo', 'PageController@pageinfo')->name('admin.page.pageinfo');
    Route::match(['get', 'post'], 'pageinfo_add', 'PageController@pageinfo_add')->name('admin.page.pageinfo_add');
    Route::match(['get', 'post'], 'pageinfo_edit/{id}', 'PageController@pageinfo_edit')->name('admin.page.pageinfo_edit');

    Route::get('chunk', 'ChunkController@chunk')->name('admin.chunk.chunk');
    Route::match(['get', 'post'], 'chunk_add', 'ChunkController@chunk_add')->name('admin.chunk.chunk_add');
    Route::match(['get', 'post'], 'chunk_edit/{id}', 'ChunkController@chunk_edit')->name('admin.chunk.chunk_edit');

    Route::get('{chunk}/sort', 'SortController@sort')->name('admin.sort.sort');
    Route::match(['get', 'post'], '{chunk}/sort_add', 'SortController@sort_add')->name('admin.sort.sort_add');
    Route::match(['get', 'post'], '{chunk}/sort_edit/{id}', 'SortController@sort_edit')->name('admin.sort.sort_edit');

    Route::any('{chunk}/info', 'InfoController@info')->name('admin.info.info');
    Route::any('{chunk}/info/trash', 'InfoController@trash')->name('admin.info.trash');
    Route::match(['get', 'post'], '{chunk}/info_add/{sort?}', 'InfoController@info_add')->name('admin.info.info_add');
    Route::match(['get', 'post'], '{chunk}/info_edit/{id}', 'InfoController@info_edit')->name('admin.info.info_edit');
    Route::post('info/addimage/{chunk}', 'ServerController@addimage')->name('admin.info.addimage');
    Route::post('info/delimage', 'ServerController@delimage')->name('admin.info.delimage');
    Route::post('info/xindex', 'ServerController@xindex')->name('admin.info.xindex');

    Route::get('box', 'BoxController@box')->name('admin.box.box');
    Route::match(['get', 'post'], 'box_add', 'BoxController@box_add')->name('admin.box.box_add');
    Route::match(['get', 'post'], 'box_edit/{id}', 'BoxController@box_edit')->name('admin.box.box_edit');

    Route::get('fragment', 'FragmentController@fragment')->name('admin.fragment.fragment');
    Route::match(['get', 'post'], 'fragment_add/{chunk}', 'FragmentController@fragment_add')->name('admin.fragment.fragment_add');
    Route::match(['get', 'post'], 'fragment_edit/{id}', 'FragmentController@fragment_edit')->name('admin.fragment.fragment_edit');

    Route::get('banner/label', 'BannerController@label')->name('admin.banner.label');
    Route::match(['get', 'post'], 'banner/label_add', 'BannerController@label_add')->name('admin.banner.label_add');
    Route::match(['get', 'post'], 'banner/label_edit/{id}', 'BannerController@label_edit')->name('admin.banner.label_edit');

    Route::get('banner/banner', 'BannerController@banner')->name('admin.banner.banner');
    Route::match(['get', 'post'], 'banner/banner_add/{label}', 'BannerController@banner_add')->name('admin.banner.banner_add');
    Route::match(['get', 'post'], 'banner/banner_edit/{id}', 'BannerController@banner_edit')->name('admin.banner.banner_edit');

    Route::get('message/message', 'MessageController@message')->name('admin.message.message');
    Route::get('message/field', 'MessageController@field')->name('admin.message.field');
    Route::match(['get', 'post'], 'message/field_add', 'MessageController@field_add')->name('admin.message.field_add');
    Route::match(['get', 'post'], 'message/field_edit/{id}', 'MessageController@field_edit')->name('admin.message.field_edit');

    Route::get('friendlylink', 'FriendlyLinkController@friendlylink')->name('admin.friendlylink.friendlylink');
    Route::match(['get', 'post'], 'friendlylink_add', 'FriendlyLinkController@friendlylink_add')->name('admin.friendlylink.friendlylink_add');
    Route::match(['get', 'post'], 'friendlylink_edit/{id}', 'FriendlyLinkController@friendlylink_edit')->name('admin.friendlylink.friendlylink_edit');

    Route::get('clear/{do?}', 'ClearController@clear')->name('admin.clear.clear');
    Route::get('debug/{do?}', 'ClearController@debug')->name('admin.clear.debug');

    Route::match(['get', 'post'], 'water', 'WaterController@water')->name('admin.water.water');

    Route::get('user', 'UserController@index')->name('admin.user.index');
    Route::match(['get', 'post'], 'user_edit/{id}', 'UserController@edit')->name('admin.user.edit');
    Route::match(['get', 'post'], 'user_delete/{id}', 'UserController@delete')->name('admin.user.delete');

    Route::get('seo/sync', 'SeoController@sync_data')->name('admin.seo.sync_data');

    Route::get('workorder/{id?}', 'WorkOrderController@index')->name('admin.workorder.index');
    Route::match(['get', 'post'], 'workorder_add', 'WorkOrderController@workorder_add')->name('admin.workorder.add');
    Route::match(['get', 'post'], 'workorder_edit/{id}', 'WorkOrderController@workorder_edit')->name('admin.workorder.edit');
});

//前台页面
Route::group(['prefix' => '/'], function () {
    //首页
    Route::get('/', 'Home\IndexController@index')->name('index');
    Route::get('index_{area}.html', 'Home\IndexController@index')->name('index_area');
    Route::get('{areaother?}/index_{area}.html', 'Home\IndexController@index');

    //关于我们
    Route::get('about/{label}_{page}.html', 'Home\PageController@index')->name('page');
    Route::get('about/{label}.html', 'Home\PageController@index')->name('page_default');
    Route::get('{area}/about/{label}_{page}.html', 'Home\PageController@index')->name('page_area');
    Route::get('{area}/about/{label}.html', 'Home\PageController@index')->name('page_default_area');

    //信息
    Route::get('{chunk}_show.html', 'Home\ChunkController@show')->name('show');
    Route::get('{area}/{chunk}_show.html', 'Home\ChunkController@show')->name('show_area');

    Route::get('{chunk}list.html', 'Home\SortController@index')->name('sort_all');
    Route::get('{area}/{chunk}list.html', 'Home\SortController@index')->name('sort_all_area');

    Route::get('{chunk}list_{sort}.html', 'Home\SortController@index')->name('sort');
    Route::get('{area}/{chunk}list_{sort}.html', 'Home\SortController@index')->name('sort_area');

    Route::get('{chunk}_{id}.html', 'Home\InfoController@index')->name('info')->where('id', '\d+');
    Route::get('{area}/{chunk}_{id}.html', 'Home\InfoController@index')->name('info_area')->where('id', '\d+');

    //在线留言
    Route::get('message/{info?}', 'Home\MessageController@index')->name('message');
    Route::get('{area}/message/{info?}', 'Home\MessageController@index')->name('message_area');

    Route::post('message', 'Home\MessageController@message')->name('message_do');
    Route::post('{area}/message', 'Home\MessageController@message')->name('message_do_area');

    //SEO
    Route::get('rss.xml', 'Home\SeoController@rss')->name('rss');
    Route::get('{area}/rss.xml', 'Home\SeoController@rss')->name('rss_area');

    Route::get('sitemap', 'Home\SeoController@sitemap')->name('sitemap');
    Route::get('{area}/sitemap', 'Home\SeoController@sitemap')->name('sitemap_area');

    Route::match(['get', 'post'], 'pushurl', 'Home\SeoController@pushurl')->name('pushurl');
    Route::match(['get', 'post'], '{area}/pushurl', 'Home\SeoController@pushurl')->name('pushurl_area');

    //搜索
    Route::get('search/{key?}', 'Home\SearchController@index')->name('search');
    Route::get('{area}/search/{key?}', 'Home\SearchController@index')->name('search_area');

});


//api
Route::get('API/Login/login.html', 'Api\ApiController@login');
Route::get('API/Login/sw_login.html', 'Api\ApiController@sw_login');
Route::get('API/Login/message.html', 'Api\ApiController@message');
Route::get('API/Login/showseo.html', 'Api\ApiController@showseo');
Route::get('API/Index/getinfo.html', 'Api\ApiController@getinfo');
Route::get('API/Index/modelinfo.html', 'Api\ApiController@modelinfo');
Route::get('API/Index/getlinknum.html', 'Api\ApiController@getlinknum');
Route::get('API/Index/getmsginfo.html', 'Api\ApiController@getmsginfo');
Route::post('API/Index/syncseo.html', 'Api\ApiController@syncseo');
Route::get('API/Index/getseo.html', 'Api\ApiController@getseo');

Route::get('API/getwebinfo', 'Api\ApiController@getwebinfo');
